package ca.uwindsor.cs.deepweb.model;

/**
 * Corpus is a Data-Access-Object (DAO) that store all necessary information of
 * a corpus.
 * 
 * @author Liang Jie
 */
public class Corpus implements Comparable<Corpus> {

	protected String name;
	protected int size;
	protected String language;
	protected String sizeindexdir;
	protected boolean isRepeatedDocumentIndex;
	protected String documentuniquetermsindex;

	/**
	 * Constructor, initialize an object
	 */
	public Corpus() {
	}

	/**
	 * Get the name of the corpus
	 * 
	 * @return the name of the corpus
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the name of the corpus
	 * 
	 * @param name
	 *            the name of the corpus
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the size of the corpus
	 * 
	 * @return the size of the corpus
	 */
	public int getSize() {
		return size;
	}

	/**
	 * Set the size of the corpus
	 * 
	 * @param size
	 *            the size of the corpus
	 */
	public void setSize(int size) {
		this.size = size;
	}

	/**
	 * Get the language of the corpus
	 * 
	 * @return the language of the corpus
	 */
	public String getLanguage() {
		return language;
	}

	/**
	 * Set the language of the corpus
	 * 
	 * @param language
	 *            the language of the corpus
	 */
	public void setLanguage(String language) {
		this.language = language;
	}

	public String getSizeindexdir() {
		return sizeindexdir;
	}

	public void setSizeindexdir(String sizeindexdir) {
		this.sizeindexdir = sizeindexdir;
	}

	public boolean isIsRepeatedDocumentIndex() {
		return isRepeatedDocumentIndex;
	}

	public void setIsRepeatedDocumentIndex(boolean isRepeatedDocumentIndex) {
		this.isRepeatedDocumentIndex = isRepeatedDocumentIndex;
	}

	public String getDocumentUniqueTermsIndex() {
		return documentuniquetermsindex;
	}

	public void setDocumentUniqueTermsIndex(String documentuniquetermsindex) {
		this.documentuniquetermsindex = documentuniquetermsindex;
	}

	/**
	 * Hash Code of this corpus, using corpus' name
	 * 
	 * @see java.lang.String#hashCode()
	 * @return hash code of corpus
	 */
	@Override
	public int hashCode() {
		return name.hashCode();
	}

	/**
	 * Compares this corpus to the specified object. The result is true if and
	 * only if the argument is not null and is a Corpus object that its name the
	 * same as this object's.
	 * 
	 * @see java.lang.String#equals(java.lang.Object)
	 * @param obj
	 *            The object to compare this Corpus against
	 * @return true if the given object represents a Corpus equivalent to this
	 *         corpus, false otherwise
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Corpus other = (Corpus) obj;
		if (this.name != other.name
				&& (this.name == null || !this.name.equals(other.name))) {
			return false;
		}
		return true;
	}

	/**
	 * Compares two Corpus. The comparison is based on their names.
	 * 
	 * @see java.lang.String#compareTo(java.lang.String)
	 * @param o
	 *            the Corpus to be compared.
	 * @return the value 0 if the argument corpus's name is equal to this
	 *         corpus' name; a value less than 0 if this corpus' name is
	 *         lexicographically less than the argument's name; and a value
	 *         greater than 0 if this corpus' name is lexicographically greater
	 *         than the argument's name.
	 */
	public int compareTo(Corpus o) {
		return name.compareTo(o.getName());
	}
}
